<template>
  <div class="myContainer">        
     <el-row class="myTitleBorderBottom">
      <el-col :span="20" class="myLineHeight_40px">
        基本信息
      </el-col>
    </el-row>
    <el-form :model="detail" :rules="rules" ref="ruleForm">   
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">     
         设备ID:
      </el-col>
      <el-col :span="7">        
            <el-input :readonly="is_modifly" v-model="device_id" placeholder="请输入设备ID"></el-input>          
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         设备名称:
      </el-col>
      <el-col :span="7">     	
           <el-input placeholder="请输入设备名称" v-model="device_name" :readonly="is_modifly"></el-input>        
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">       
         设备SN号:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_sn" placeholder="请输入设备SN号"></el-input>         
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">       
         设备类型:
      </el-col>
      <el-col :span="7">     
            <el-input :readonly="is_modifly" v-model="device_type_name" placeholder="请输入设备类型"></el-input>         
      </el-col>
    </el-row>
     <el-row class="myMarginTop_10px">
     <el-col :span="3" class="myLeftMsg">    	
         是否已经删除:
      </el-col>
      <el-col :span="7">     	
        <template>
          <el-select 
            v-model="activate_status"
            :disabled="is_modifly"
            clearable
            placeholder="设备激活状态">
            <el-option
              v-for="item in activeStatusList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>       
      </el-col>
    </el-row> 
     <el-row class="myMarginTop_10px">
     <el-col :span="3" class="myLeftMsg">    	
         是否已经删除:
      </el-col>
      <el-col :span="7">     	
        <template>
          <el-select 
            v-model="del_flag"
            :disabled="is_modifly"
            clearable
            placeholder="是否已经删除">
            <el-option
              v-for="item in deleteSignList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>        
      </el-col>
    </el-row> 
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">       
         所属区域:
      </el-col>
       <el-col :span="7">      
            <el-input :readonly="is_modifly" v-model="area_name" placeholder="请输入所属区域"></el-input>          
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">       
         组织ID:
      </el-col>
     <el-col :span="7">      
            <el-input :readonly="is_modifly" v-model="org_id" placeholder="请输入组织ID"></el-input>         
      </el-col>
    </el-row>
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         所属租户ID:
      </el-col>
    <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="tenant_id" placeholder="请输入所属租户ID"></el-input>          
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">     	
           设备创建时间:
      </el-col>
      <el-col :span="7">
        <el-date-picker
          v-model="create_time"
          :disabled="is_modifly"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="请选择设备创建时间">
        </el-date-picker>  
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">      	
        设备激活时间:
      </el-col>
      <el-col :span="7">
        <el-date-picker
          v-model="activate_time"
          :disabled="is_modifly"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="请选择设备激活时间">
        </el-date-picker>  
      </el-col>
    </el-row>
    <el-row class="myTitleBorderBottom myMarginTop_10px">
        <el-col :span="20" class="myLineHeight_40px">
          网络及升级状态
        </el-col>
      </el-row>
      <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">      	
         连接状态:
      </el-col>
      <el-col :span="7">
        <template>
          <el-select 
            v-model="connect_status"
            :disabled="is_modifly"
            clearable
            placeholder="请选择连接状态">
            <el-option
              v-for="item in connectList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
      </el-col>
    </el-row> 
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">     	
         升级包状态:
      </el-col>
      <el-col :span="7">
        <template>
          <el-select 
            v-model="upgrade_pack_status"
            :disabled="is_modifly"
            clearable
            placeholder="请选择升级包状态">
            <el-option
              v-for="item in upgradePackageList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
      </el-col>
    </el-row> 
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">     	
         升级状态:
      </el-col>
      <el-col :span="7">
        <template>
          <el-select 
            v-model="upgrade_progress"
            :disabled="is_modifly"
            clearable
            placeholder="请选择升级状态">
            <el-option
              v-for="item in upgradeList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
      </el-col>
    </el-row> 
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">       
         设备版本名称:
      </el-col>
     <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_version" placeholder="请输入设备版本名称"></el-input>          
      </el-col>
    </el-row>
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">      
         设备版本号:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_version_code" placeholder="请输入设备版本号"></el-input>          
      </el-col>
    </el-row>
      <el-row class="myTitleBorderBottom myMarginTop_10px">
        <el-col :span="20" class="myLineHeight_40px">
          参数信息
        </el-col>
      </el-row>
       <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">      
         设备IP:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_ip" placeholder="请输入设备IP"></el-input>         
      </el-col>
    </el-row>
         <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">       
         设备端口:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_port" placeholder="请输入设备端口"></el-input>          
      </el-col>
    </el-row>
         <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         人脸检测阀值:
      </el-col>
      <el-col :span="7">     
            <el-input :readonly="is_modifly" v-model="device_face_threshold" placeholder="请输入人脸检测阀值"></el-input>         
      </el-col>
    </el-row>
        <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">       
         储存容量:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="storage" placeholder="请输入储存容量"></el-input>          
      </el-col>
    </el-row>
        <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         宽带:
      </el-col>
      <el-col :span="7">      
            <el-input :readonly="is_modifly" v-model="bandwidth" placeholder="请输入宽带"></el-input>
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
     <el-col :span="3" class="myLeftMsg">        
         制造商:
      </el-col>
     <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="manufacture" placeholder="请输入制造商"></el-input>          
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        出厂日期:
      </el-col>
      <el-col :span="7">
        <el-date-picker
          v-model="mage_date"
          :disabled="is_modifly"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="请选择出厂日期">
        </el-date-picker>  
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="7" :offset="3">
        <!--<el-button type="primary" class="myBgGreen" v-if="type=='update'" @click="onEditAd">保 存</el-button>
        <el-button type="primary" class="myBgGreen" v-if="type=='add'" @click="onCreate">权限下放</el-button>-->
        <el-button type="primary" class="myBgGreen" @click="onBack">返 回</el-button>
      </el-col>
    </el-row>
  </el-form>  
    
  </div>
</template>
<style scoped>
  .myContainer{
    background: #fff;
    padding: 10px;
  }
  .myTitleBorderBottom{
    color: #000;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #dbdbdb;
  }
  .myBgGreen{
    background: #00c2a9;
    border-color: #00c2a9;
    color: #fff;
    margin-top:2px;
  }
  .myBgGreen:hover{
    background: #33ceba;
  }
  .myTextAlignRight{
    text-align: right;
  }
  .myLineHeight_40px{
    line-height: 40px;
  }
  .myMarginTop_10px{
    margin-top: 10px;
  }
  .myLeftMsg{
    line-height: 40px;
    text-align: right;
    padding-right: 10px;
  }
  .myMarginTop_10px{
    padding-bottom: 10px;
  }
  .myVA_M{
    vertical-align: middle;
  }
  .myMarginBottom_10px{
    margin-bottom: 20px;
  }
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
    border:1px solid #d8dce5;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>

<script>
  import { getJumpValue , addAd , getAd , editAd } from '@/api/online';
  import { getFaceDetail } from '@/api/entrance_guard';
  import { r_email , r_phone } from "@/api/regular";//正则
  export default {
    data(){
      return{
        title: "人脸识别管理",
        id: "",
        is_modifly:false,
        type:"",
        ad_name:"",
         detail:{
          
        },                   
            
        device_id:"",
        device_name:"",
        device_sn:"",
        device_type_name:"",        
        area_name:"",
        org_id:"",
        tenant_id:"",
        create_time:"",
        activate_time:"",
        device_version:"",
        device_version_code:"",
        
        device_ip:"",
        device_port:"",
        device_face_threshold:"",
        storage:"",
        bandwidth:"",
        manufacture:"",
        mage_date:"",
        del_flag:"",
        deleteSignList:[{value:0,label:"未删除"},{value:1,label:"已删除"}],
        activate_status:"",
        activeStatusList:[{value:0,label:"已激活"},{value:1,label:"未激活"}],
        connect_status:"",
        connectList:[{value:1,label:"未连接"},{value:2,label:"已连接"}],
        upgrade_pack_status:"",
        upgradePackageList:[{value:0,label:"无升级包"},{value:1,label:"有升级包"}],
        upgrade_progress:"",
        upgradeList:[{value:0,label:"可升级"},{value:1,label:"正在下载"},{value:2,label:"升级"},{value:3,label:"升级等待"},{value:4,label:"正在升级"},{value:5,label:"暂停升级"}],
        rules: {
         
          card_no:[
            {required: true, message: '不能为空！', trigger: 'blur'},
            
            ],          
          },
      }
    },
    components: {
        
    },
    created(){
      document.title=this.title;
      this.type = this.$route.query.type;
      this.id = this.$route.query.id;
      if(this.type=='add'){

      }
      if(this.type=='info'){
        this.onGetAd();
        this.is_modifly = true;
        this.is_disabled = true;
      }
      
    },
    methods:{     
      onEditAd(){
        let vm=this;
        let params={          
          ADDESC:vm.ADDESC,
         
        }
        editAd(params).then(response => {
          console.log("修改成功")
          this.$message.success('执行成功！');
          this.$router.go(-1);
        }).catch(error => {
          this.$message.error('执行失败！');
          console.log("修改失败")
        })
      },
      onCreate(){//添加
        let vm=this;
        let params={
        
          ADDESC:vm.ADDESC,
        }
        addAd(params).then(response => {
          let res=response.data;
          vm.$message.success("添加数据成功！");
          this.$router.go(-1);
          console.log("添加成功",res);
        }).catch(error => {
          vm.$message.error("添加数据失败！");
          console.log("添加失败",error);
        })
        console.log(params)
      },
      onBack(){//返回
      	let vm =this;
      	window.localStorage.setItem('pageNum',vm.$route.query.pageNum||1);
        this.$router.go(-1);
      },
      
      onGetAd(){//拉取
        let vm=this;      
        getFaceDetail(vm.id).then(response => {               
          let res=response.data;
          vm.device_id=res.device_id;
          vm.device_name=res.device_name;
          vm.device_sn=res.device_sn;
          vm.activate_status=res.activate_status;
          vm.area_name=res.area_name;
          vm.org_id=res.org_id;
          vm.create_time=res.create_time;
          vm.tenant_id=res.tenant_id;
          vm.activate_time=res.activate_time;
          vm.device_version=res.device_version;
          vm.device_version_code=res.device_version_code;
          vm.device_ip=res.device_ip;
          vm.device_port=res.device_port;
          vm.device_face_threshold=res.device_face_threshold;
          vm.storage=res.storage;
          vm.device_type_name=res.device_type_name;
          vm.bandwidth=res.bandwidth;
          vm.manufacture=res.manufacture;
          vm.mage_date=res.mage_date;
          vm.del_flag=res.del_flag;
          vm.connect_status=res.connect_status;
          vm.upgrade_pack_status=res.upgrade_pack_status;
          vm.upgrade_progress=res.upgrade_progress;
        }).catch(error => {
          console.log("拉取数据失败",error);
        })
      }            
    }
  
  }


</script>



